#ifndef HANDLE_H
#define HANDLE_H
#pragma execution_character_set("utf-8")
#include <QObject>
#include <QDebug>
#include <local_socket.h>
#include <tcp_socket.h>
#include <QTime>
#include <QCoreApplication>
#include <QFile>
#include <QFileInfo>
#include <common.h>
#include <caculate_task.h>
#include <mysql.h>
#include <QDir>
class Handle : public QObject
{
    Q_OBJECT
public:
    Handle(QString num,bool connect_sql);
    mysql sql;
    QString num;
private:
    bool isFileExist(QString fullFileName);    //是否存在对应文件
    bool isDirExist(QString fullPath);         //是否存在对应文件夹，不存在则创建
    QString rand_id(int length);
    void Assignment_task();                    //分配任务
    void read_unfinish_task();                 //从数据库中读取未完成的任务
    void SumResult(QString C_Taskid);          //Caculate_Task计算完毕，将其结果进行综合
    void FindFinsh_Task();                     //查找完成的任务
    void LocalSockt_unfinshsenddata(local_socket *l_socket);         //发送Localsocket未发送的任务
    void LocalSocket_SetUnfinshsenddata(QString id,QString type,QString data,emit_type emittype,QString sockettype);     //设置Localsocket未发送的任务
    void ReadDll();
    QString GetMD5(QByteArray data);
    QStringList GetDLLMd5();                  //获取Dll文件中所有MD5值
    QString CaculateNode_information();
    void handle_local(QString id, QString type, QString data,local_socket *l_socket,Handle *handle,emit_type te_ype);
    void handle_tcp(QString id, QString type, QString data, tcp_socket *t_socket,Handle *handle,emit_type te_ype);
signals:
    void l_SocketSendData(QString id,QString type,QString data,local_socket *l_socket,emit_type te_ype,QString socketType);
    void t_SocketSendData(QString id,QString type,QString data,tcp_socket *t_socket,emit_type te_ype,QString socketType);
    void finish_Task();
private slots:
    void handle_localSocket(QString id, QString type, QString data,local_socket *l_socket,Handle *handle,emit_type te_ype);
    void handle_tcpSocket(QString id, QString type, QString data, tcp_socket *t_socket,Handle *handle,emit_type te_ype);                       //处理来自tcp_socket请求
};

#endif // HANDLE_H
